CC := gcc
SRC := $(shell find src -name "*.c")
INC := ./inc /usr/include/python3.9/ /usr/include 

OBJ := $(subst src/,obj/,$(SRC:.c=.o))

TARGET=obj/smarthome

CFLAGS := $(foreach item, $(INC),-I$(item))

LIBS := -lwiringPi -lpython3.9 -pthread -lexpat -lz -lcrypt -lrt -linih

obj/%.o:src/%.c
	mkdir -p obj
	$(CC) -o $@ -c $< $(CFLAGS)

$(TARGET) :$(OBJ)
	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)

compile : $(TARGET)
clean:
	rm $(TARGET) obj $(OBJ) -rf
debug:
	echo $(CC)
	echo $(SRC)
	echo $(INC)
	echo $(OBJ)
	echo $(TARGET)
	echo $(CFLAGS)
	echo $(LDFLAGS)
	echo $(LIBS)
.PHONY: clean compile debug